home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Presentations / Presentations ’88 / Fritz Proceedings stuff / PatchLMgr.c < prev    next >
Text File  |  1988-06-14  |  3KB  |  118 lines

  1. /*
  2.  *    PatchLMgr.c
  3.  *
  4.  *    Created    Thursday, March 31, 1988 5:10:17 PM
  5.  */
  6.  
  7. #include <QuickDraw.h>
  8. #include "SetEditor.h"
  9.  
  10. typedef struct {
  11.     short        baseLine;
  12.     RgnHandle    cellRgn;
  13.     }    LRefCon, *LRCPtr, **LRCHandle;
  14.  
  15. #define LBaseLine(list)    ((*(LRCHandle)(*list)->refCon)->baseLine)
  16. #define LCellRgn(list)    ((*(LRCHandle)(*list)->refCon)->cellRgn)
  17.  
  18. /*
  19.  *    Our story so far:
  20.  *
  21.  *    When a list is scrolled, the List Manager calls LUpdate internally,
  22.  *    drawing all the cells that are exposed; it then disposes of ScrollRect's
  23.  *    invalidation region.  All very well, but the List Manager no longer
  24.  *    knows all there is to know about the state of a set editor list:
  25.  *    The UI application itself handles highlighting of units larger than
  26.  *    single cells.  The result is that when cells in a highlighted row or
  27.  *    column are drawn unhighlighted when they are exposed, and the UI is
  28.  *    never notified of an update.
  29.  *
  30.  *    The solution is to patch _Pack0 (the List Manager dispatcher) at LUpdate;
  31.  *    At that point, we can take note of the invalid region, clip to it, and
  32.  *    highlight.
  33.  *
  34.  *    We can also take this opportunity to install the long-awaited patch
  35.  *    that will allow the labels to be drawn in synch with a scrolling array.
  36.  *    The List Manager never calls its mouseDown hook when a list's scroll bars
  37.  *    are hit, and so this is the best available hook.
  38.  *
  39.  *    The actual patch should be in assembly language, which will save us
  40.  *    the trouble of always doing the right thing by _Pack0's variable-length
  41.  *    argument list.  This file contains only the high-level parts of the patch;
  42.  *    the glue is in PatchLMgr.a.
  43.  */
  44.  
  45. #define __SEG__ Init
  46.  
  47. InstallPatch()
  48. {
  49.     LUPatIn();
  50.     }
  51.  
  52. #define __SEG__ Main
  53.  
  54. LUpdatePatch(lHandle, theRgn)
  55. ListHandle    lHandle;
  56. RgnHandle    theRgn;
  57. {
  58.     RgnHandle    tempRgn,
  59.                 freshRgn;
  60.     SetEdPtr    theWindow;
  61.     GrafPtr        oldPort;
  62.     
  63.     theWindow = (*lHandle)->port;
  64.     if (Peek(theWindow)->windowKind != setEditor)
  65.         return;
  66.     
  67.     GetPort(&oldPort);
  68.     SetPort(theWindow);
  69.     
  70.     tempRgn = NewRgn();
  71.     GetClip(tempRgn);
  72.         
  73.     UnionRgn(LCellRgn(lHandle), theRgn, freshRgn = NewRgn());
  74.     SetClip(freshRgn);
  75.     DisposeRgn(freshRgn);
  76.  
  77.     AdjustLabels(theWindow);    
  78.     InvertSel(theWindow);
  79.     
  80.     SetClip(tempRgn);
  81.     DisposeRgn(tempRgn);
  82.     
  83.     SetPort(oldPort);
  84.     }
  85.  
  86. /*    The following patch, believe it or not, does _not_
  87.  *    re-enter.  The actual patch code directs all calls
  88.  *    to ScrollRect(), other than from the List Manager,
  89.  *    to the trap itself.
  90.  */
  91.  
  92. pascal void MyScrRect(r, dh, dv, updateRgn)
  93. Rect        *r;
  94. short        dh,
  95.             dv;
  96. RgnHandle    updateRgn;
  97. {
  98.     SetEdPtr    theWindow;
  99.     Rect        myRect;
  100.     ListHandle    SEList();
  101.  
  102.     GetPort(&theWindow);
  103.     if (Peek(theWindow)->windowKind == setEditor) {
  104.         /*    First, expand the scrolling Rect to include the labels:    */
  105.         myRect = *r;
  106.         if (dh) {
  107.             myRect.top -= TITLE_HEIGHT;
  108.             }
  109.         else if (dv) {
  110.             myRect.left -= LABEL_WIDTH;
  111.             }
  112.         ScrollRect(&myRect, dh, dv, updateRgn);
  113.         SetEmptyRgn(LCellRgn(SEList(theWindow)));
  114.         }
  115.     else
  116.         ScrollRect(r, dh, dv, updateRgn);
  117.     }
  118.